import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Login from '../views/login/index.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path:'/',
    redirect:"/login"
  },
  {
    path:'/login',
    name:'login',
    component:Login
  },
  {
    path:'/home',
    name:'home',
    component:() => import(/* webpackChunkName: "home" */'../views/HomeView/index.vue'),
    redirect:'/echarts',
    children:[
      {
        path:'/echarts',
        name:'echarts',
        component:() => import(/*webpackChunkName:'echarts'*/'../views/HomeChildren/EchartsView.vue'),
        meta:{
          title:'数据展示'
        }
      },
      {
        path:'/permissionlist',
        name:'permissionlist',
        component:() => import(/*webpackChunkName:'permissionlist'*/'../views/HomeChildren/PermissionList.vue'),
        meta:{
          title:'权限列表'
        }
      },
      {
        path:'/user',
        name:'user',
        component:() => import(/*webpackChunkName:'user'*/'../views/HomeChildren/UserOne.vue'),
        redirect:'/userlist',
        meta:{
          title:'住户信息'
        },
        children:[
          {
            path:'/userlist',
            name:'userlist',
            component:() =>import(/*webpackChunkName:'userlist'*/'../views/HomeChildren/UserlList.vue'),
            meta:{
              // 分类标题
              classifyTitle:"用户信息",
              title:"住户列表"
            }
          },
          {
            path:'/userupdate',
            name:'userupdate',
            component:() => import(/*webpackChunkName:'userupdate'*/'../views/HomeChildren/UserUpdate.vue'),
            meta:{
              // 分类标题
              classifyTitle:"用户信息",
              title:"住户列表修改"
            }
          }
        ]
      },
    ]
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
